package com.hefu.virtuallife.base;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.hefu.virtuallife.R;
import com.hefu.virtuallife.utils.GoWhere;
import com.hefu.virtuallife.utils.ToastUtils;

/**
 * Created by zc on 2018/7/3.
 */

public class MainLayoutPanel extends BasePanel {

    private ImageView mImageViewHolder;
    private TextView mtextView;

    //Constructors
    public MainLayoutPanel(Context context) {
        this(context, null);
    }

    public MainLayoutPanel(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public MainLayoutPanel(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initLayoutPanel();
    }

    public void setImageResId(int resId) {
        mImageViewHolder.setImageResource(resId);
    }

    public void setText(String str) {
        mtextView.setText(str);
    }

    private void initLayoutPanel() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.activity_main_circular_item, null);
        mImageViewHolder = view.findViewById(R.id.img_bg);
        mtextView = view.findViewById(R.id.tv_type);
        mPanelContainer.addView(view);
        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String str = mtextView.getText().toString();
                GoWhere.go(str);
            }
        });
    }
}
